<extend name="template/base_index" />

<block name="area_header">
    <link rel="stylesheet" type="text/css" media="all" href="__CSS__/wxshop.css">
    <link type="text/css" rel="stylesheet" src="__CDN__/jquery-uploadify/3.2.1/uploadify.css" />
    <script type="text/javascript" src="__CDN__/jquery-uploadify/3.2.1/jquery.uploadify.min.js"></script>
    <link type="text/css" rel="stylesheet" href="__CDN__/select2/3.5.2/select2.css" />
    <script type="text/javascript" src="__CDN__/select2/3.5.2/select2.min.js"></script>
    <script type="text/javascript" src="__CDN__/select2/3.5.2/select2_locale_zh-CN.js"></script>
</block>

<block name="area_body">
    {:W('Menus/topbar')}
    <div class="admin-main container-fluid">
        {:W('Menus/left')}
        <div class="admin-main-content">
            {:W('Menus/breadcrumb')}

            <div class="col-main">
                <div class="main-hd">
                    <h2>编辑商品</h2>
                </div>
                <div class="main-bd clearfix" style="padding: 0 10px;margin-top: 0px;">
                    <form class="productForm form-horizontal" method="post">
                        <input type="hidden" name="id" value="{$product.id}" />
                        <input type="hidden" name="name" value="{$product.name}" />
                        <input type="hidden" name="has_sku" value="{$product.has_sku}" />

                        <h3><i>●</i>基本信息</h3>
                        <div class="form-group col-lg-12 col-md-12 clearfix">
                            <label for="" class="control-label col-lg-2 col-md-2">商品名称</label>
                            <div class="col-lg-10 col-md-10">{$product.name}

                            </div>
                        </div>

                        <if condition="$product['has_sku'] == 1">
                            <volist name="sku_list"  id="vo">
                                <div class="form-group col-lg-12 col-md-12 clearfix">
                                    <label for="" class="control-label col-lg-2 col-md-2">当前库存</label>
                                    <div class="col-lg-10 col-md-10">{$vo.quantity}(<span class="text-danger">{$vo.sku_desc}</span>)
                                    </div>
                                </div>

                                <div class="form-group col-lg-12 col-md-12 clearfix">
                                    <label for="" class="control-label col-lg-2 col-md-2">库存增加</label>
                                    <div class="col-lg-10 col-md-10">

                                        <input type="hidden" name="quantity[]" value="{$vo.quantity}" />

                                        <input type="hidden" name="sku_desc[]" value="{$vo.sku_desc}" />
                                        <!--<input type="hidden" name="sku_id[]" value="{$key}" />-->
                                        <input type="hidden" name="sku_id[]" value="{$vo.product_code}" />
                                        <input type="text" name="putin[]" value="0" />
                                        <span class="help-block">例如6 </span>
                                    </div>
                                </div>

                            </volist>

                            <else/>
                            <div class="form-group col-lg-12 col-md-12 clearfix">
                                <label for="" class="control-label col-lg-2 col-md-2">当前库存</label>
                                <div class="col-lg-10 col-md-10">{$product.quantity}
                                </div>
                            </div>
                            <div class="form-group col-lg-12 col-md-12 clearfix">
                                <label for="" class="control-label col-lg-2 col-md-2">库存增加</label>
                                <div class="col-lg-10 col-md-10">
                                    <input type="hidden" name="product_code" value="{$product.product_code}" />

                                    <input type="text" name="putin" value="0" />
                                    <span class="help-block">例如6</span>
                                </div>
                            </div>

                        </if>

                        <div class="form-group col-lg-12 col-md-12 clearfix tool-bar text-center border">

                            <a data-loading-text="正在上报网仓..."  target-form="productForm" href="{:U('Admin/Product/putin')}"  class="ajax-post btn btn-primary" id="js_submit"><i class="fa fa-check"></i>保存</a>
                            <a href="{:U('Admin/Product/index',array('store_id'=>$vo['store_id'],'onshelf'=>$onshelf,'p'=>$p))}" class="btn btn-default"><i class="fa fa-reply"></i>返回</a>
                        </div>


                    </form>
                </div>

                <div style="padding: 0 10px;margin-top: 0px;">
                    <h2 class="h5">网仓的库存信息(同步时间:[{:date('Y-m-d H:i:s',time())}])</h2>
                    <table class="table table-bordered table-striped table-hover">
                        <thead>
                        <tr>
                            <th>
                                序号
                            </th>
                            <th>
                                商品编码
                            </th>
                            <th>
                                库存
                            </th>

                            <th>
                                库存类型
                            </th>

                            <th>
                                操作
                            </th>

                        </tr>
                        </thead>
                        <tbody>
                        <empty name="inventory_list">
                            <tr>
                                <td class="text-center" colspan="4">无相关数据</td>
                            </tr>
                            <else/>
                            <volist name="inventory_list" id="vo">

                                <tr>
                                    <td>
                                        {:($key+1)}
                                    </td>
                                    <td>
                                        {$vo.itemId}
                                    </td>
                                    <td>

                                        在架数:{$vo.qtyOnLocation}<br/>
                                        已拣选,未出库: {$vo.qtyOfShipping}<br/>
                                        可售数：{$vo.qtyOfAvailable}<br/>
                                    </td>

                                    <td>
                                        {:($vo['inventoryType'] == '1'?'可销售库存':"残次品")}
                                    </td>
                                    <td>
                                        <eq name="vo['inventoryType']" value="1">
                                            <a href="{:U('Admin/Product/sync_quantity',array('available'=>$vo['qtyOfAvailable'],'item_id'=>$vo['itemId']))}" class="ajax-get btn btn-primary btn-sm"><i class="fa fa-refresh"></i>同步销售库存</a>
                                            <else/>
                                            残次品不能作为销售库存
                                        </eq>
                                    </td>

                                </tr>

                            </volist>
                        </empty>
                        </tbody>
                    </table>
                </div>

                <div style="padding: 0 10px;margin-top: 0px;">
                    <h2 class="h5">库存变动纪录</h2>
                    <table class="table table-bordered table-striped table-hover">
                        <thead>
                            <tr>
                                <th>
                                    序号
                                </th>
                                <th>
                                    时间
                                </th>
                                <th>
                                    库存变动
                                </th>

                                <th>
                                    商品规格
                                </th>
                                <th>
                                    操作
                                </th>

                            </tr>
                        </thead>
                        <tbody>
                        <empty name="stock_his_list">
                            <tr>
                                <td class="text-center" colspan="4">无相关数据</td>
                            </tr>
                            <else/>
                            <volist name="stock_his_list" id="vo">

                                <tr>
                                    <td>
                                        {:($key+1)}
                                    </td>
                                    <td>
                                        {$vo.create_time|date='Y-m-d H:i:s',###}
                                    </td>
                                    <td>
                                        期望:{$vo.expect_putin_cnt} 实际入库:<span class="text-danger"> {$vo.real_putin_cnt} </span>
                                    </td>

                                    <td>
                                        {$vo.sku_desc|default='无规格'}
                                    </td>
                                    <td>
                                        <eq name="vo['real_putin_cnt']" value="0">

                                            <eq name="vo['cancel_status']" value="0">
                                            <a href="{:U('Admin/NetWH/cancelPurchse',array('code'=>$vo['in_storage_code']))}" class="btn btn-primary btn-sm ajax-get"><i class="fa fa-times"></i>取消入库</a>
                                            <else/>
                                                <span>已取消</span>
                                            </eq>
                                            <else/>
                                            <span>已入库，无法取消</span>
                                        </eq>
                                    </td>
                                </tr>

                            </volist>
                        </empty>
                        </tbody>
                    </table>
                    {$show}
                </div>

            </div>



    </div>
    <!-- END admin-main-content -->
    </div>
    <!-- END admin-main-->
</block>

<block name="area_footer">


</block>